package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;

//本类是用来演示JDBC获取数据库的演示demo
public class TestConnection {
    public static void main(String[] args) throws Exception {
        //1.加载驱动
        Class.forName("com.mysql.jdbc.Driver");
        //2.获取和数据库的链接
        //2.1指定URL 确定要链接的是那个数据库
        String url = "jdbc:mysql://localhost:3306/tedu?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai";
        //2.2指定用户名和密码
        String user = "root";
        String psd = "root";
        //2.3调用DriverManager的getConnection方法获取链接
        Connection conn = DriverManager.getConnection(url, user, psd);
        System.out.println("连接成功");

    }
}
